package com.wz.project.bas.workshopChangeRd.controller;

import com.wz.framework.web.controller.BaseController;
import com.wz.framework.web.domain.AjaxResult;
import com.wz.framework.web.page.TableDataInfo;
import com.wz.project.bas.workshopChangeRd.domain.WorkshopChangeRd;
import com.wz.project.bas.workshopChangeRd.service.IWorkshopChangeRdService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 基础车间班组交接班记录 信息操作处理
 * 
 * @author sys
 * @date 2021-10-28
 */
@Controller
@RequestMapping("/bas/workshopChangeRd")
public class WorkshopChangeRdController extends BaseController
{
    private String prefix = "bas/workshopChangeRd";
	
	@Autowired
	private IWorkshopChangeRdService workshopChangeRdService;
	
//	@RequiresPermissions("module:bas:view")
	@GetMapping()
	public String workshopChangeRd()
	{
	    return prefix + "/workshopChangeRd";
	}
	
	/**
	 * 查询基础车间班组交接班记录列表
	 */
//	@RequiresPermissions("module:workshopChangeRd:list")
	@PostMapping("/list")
	@ResponseBody
	public TableDataInfo list(WorkshopChangeRd workshopChangeRd)
	{
		startPage();
        List<WorkshopChangeRd> list = workshopChangeRdService.selectWorkshopChangeRdList(workshopChangeRd);
		return getDataTable(list);
	}
	
	/**
	 * 新增基础车间班组交接班记录
	 */
	@GetMapping("/add")
	public String add()
	{
	    return prefix + "/add";
	}
	
	/**
	 * 新增保存基础车间班组交接班记录
	 */
	@RequiresPermissions("module:workshopChangeRd:add")
	@PostMapping("/add")
	@ResponseBody
	public AjaxResult addSave(WorkshopChangeRd workshopChangeRd)
	{
		String s = String.valueOf(System.currentTimeMillis());
		String substring = s.substring(s.length() - 6);
//        int pejId = Integer.parseInt(substring);
		workshopChangeRd.setId(substring);
		return toAjax(workshopChangeRdService.insertWorkshopChangeRd(workshopChangeRd));
	}

	/**
	 * 修改基础车间班组交接班记录
	 */
	@GetMapping("/edit/{id}")
	public String edit(@PathVariable("id") String id, ModelMap mmap)
	{
		WorkshopChangeRd workshopChangeRd = workshopChangeRdService.selectWorkshopChangeRdById(id);
		mmap.put("workshopChangeRd", workshopChangeRd);
	    return prefix + "/edit";
	}
	
	/**
	 * 修改保存基础车间班组交接班记录
	 */
	@RequiresPermissions("module:workshopChangeRd:edit")
	@PostMapping("/edit")
	@ResponseBody
	public AjaxResult editSave(WorkshopChangeRd workshopChangeRd)
	{		
		return toAjax(workshopChangeRdService.updateWorkshopChangeRd(workshopChangeRd));
	}
	
	/**
	 * 删除基础车间班组交接班记录
	 */
	@RequiresPermissions("module:workshopChangeRd:remove")
	@PostMapping( "/remove")
	@ResponseBody
	public AjaxResult remove(String ids)
	{		
		return toAjax(workshopChangeRdService.deleteWorkshopChangeRdByIds(ids));
	}
	
}
